package DoublyLinkedListSentinel;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.List;

public class DoublyLinkedListSentinel2Test {
    DoublyLinkedListSentinel list = new DoublyLinkedListSentinel();

    @Test
    void addFirst() {
        list.addFirst(3);
        Assertions.assertIterableEquals(List.of(3),list);
    }

    @Test
    void insert() {
        list.insert(1,0);
        list.insert(2,1);
        list.insert(3,2);
        list.insert(4,3);
        Assertions.assertIterableEquals(List.of(1,2,3,4),list);
    }

    @Test
    void removeFirst() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.removeFirst();
        Assertions.assertIterableEquals(List.of(2,3,4),list);
    }

    @Test
    void addLast() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        Assertions.assertIterableEquals(List.of(1,2,3,4),list);
    }

    @Test
    void removeLast() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.removeLast();
        Assertions.assertIterableEquals(List.of(1,2,3),list);
    }

    @Test
    void remove() {
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        list.remove(2);
        Assertions.assertIterableEquals(List.of(1,2,4),list);
    }
}
